#version 450

layout(location = 0) in vec2 fragOffset;
layout(location = 0) out vec4 outColor;

struct PointLight {
    vec4 position;
    vec4 color;
    // float radius;
};

layout(set = 0, binding = 0) uniform GlobalUbo {
    mat4 projection;
    mat4 view;
    mat4 inverseView;
    vec4 ambientLightColor;
    PointLight pointLights[10];
    int numLights;
} ubo;

layout(set = 0, binding = 1) uniform sampler2D texSampler;

layout(push_constant) uniform Push {
   vec4 position;
   vec4 color;
   float radius;
} push;

const float PI = 3.14159265359;
// float step(float a, float x) {
//     return x >= a ? 1.0 : 0.0;
// }
// float smoothstep(float a, float b, float x) {
//     float t = clamp((x - a)/(b - a), 0.0, 1.0);
//     return t * t * (3.0 - 2.0 * t);
// }
// float smootherstep(float a, float b, float x) {
//     float t = clamp((x - a)/(b - a), 0.0, 1.0);
//     return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
// }

float getLightAlpha(vec2 fragOffset) {
    float dis = length(fragOffset);
    float alpha = smoothstep(0.0, 1.0, dis);
    // float alpha = smootherstep(0.0, 1.0, dis);
    return alpha;
}

void main()
{
    float dis = length(fragOffset);
    if(dis >= 1.0) {
        discard;
    }
    // vec2 uv = fragOffset * 0.5 + 0.5;
    outColor = vec4(push.color.xyz, getLightAlpha(fragOffset));
}
